<?php
/**
 * @author SNOWTAM
 * @purpose customtextout.txt to get the station battery voltage iserted into a mysql table        
 * @created 2008-12-17
 */

require("config/db_config.php");
	$connection = mysql_connect($db_host, $db_user, $db_password) or die("Unable to connect");
	mysql_select_db($db_name, $connection);

$handle = @fopen($weather_server, "r");
if (!$handle)
    die("Could not open file!");

	while (!feof($handle)) {
    $buffer = fgets($handle);
    $rad = explode("|", $buffer);
    //echo $rad;
    $Tid = $rad[0]."-".$rad[1]."-".$rad[2]." ".$rad[3].":".$rad[4].":00";
    $lvs_sql = "REPLACE INTO weather_bat (date_stamp,voltage) values ('".$Tid."','".$rad[10]."');";
	mysql_query($lvs_sql);
}
fclose($handle);
echo "Done!";
?>
